<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
<script>
    // //第一题 对象键值下标
    var obj = {}
    obj.p1 = "str1"
    obj.p6 = "str6"
    obj.p2 = "str2"

    obj[1] = "num1"
    obj[6] = "num6"
    obj[2] = "num2"

    for (var p in obj) {
        console.log(obj[p])
    }

    // /*
    // num1
    // num2
    // num6
    // str1
    // str6
    // str2
    // */

    // console.log(obj[0]) // undefined
    //     //第二题 promise和setTimeOut顺序
    let d = new Date()
    console.log(1, new Date() - d)
    setTimeout(() => {
        console.log(2, new Date() - d)
    }, 500);
    Promise.resolve().then(() => {
        console.log(3, new Date() - d)
    })

    // while ((new Date() - d) < 1000) {
    //     console.log(4, new Date() - d)
    // }
    //第三题 promise和setTimeOut顺序
    setTimeout(() => {
        console.log('setTimeOut')
    }, 0);

    const f = new Promise(resolve => {
        console.log('a')
        resolve()
        console.log('b')
    })

    f.then(() => {
        console.log('c')
        setTimeout(() => {
            console.log('d')
        }, 0);
    })
</script>
</body>

</html>

